/*$('.card-datatable').DataTable({
	 "ajax" : {
		"url" : contextpath + "customerBankCard/list?customerId=" + $("#customerId").val(),
		"data" : function(d) {
            var query = $("#query").serializeObject();
            query["size"] = d.length;
            query["page"] = (d.start/d.length);
			return query;
		},
		"dataFilter": function(data){
            var json = jQuery.parseJSON( data );
            json.recordsTotal = json.totalElements;
            json.recordsFiltered = json.totalElements;
            json.data = json.content;
 
            return JSON.stringify( json );
        }
	 },
	 "columns": [
         { "data": "bankCardNum" },
         { "data": "bankName" },
         { "data": "customerName" },
         { "data": "bankCardType" }
     ],
     "drawCallback": function( settings ) {
      }
});*/

$('.cOrder-datatable').DataTable({
	 "ajax" : {
		"url" : contextpath + "cOrder/list?customerId=" + $("#customerId").val(),
		"data" : function(d) {
           var query = $("#query").serializeObject();
           query["size"] = d.length;
           query["page"] = (d.start/d.length);
			return query;
		},
		"dataFilter": function(data){
           var json = jQuery.parseJSON( data );
           json.recordsTotal = json.totalElements;
           json.recordsFiltered = json.totalElements;
           json.data = json.content;

           return JSON.stringify( json );
       }
	 },
	 "columns": [
	     { "data": "customerName" },
	     { "data": "customerPhoneNo" },
        {
	    	 render : function(data, type, row, meta) {
	    		 if(row.distributorShopName){
	    			 return row.distributorShopName + '(' + row.distributorName + ')';
	    		 }else{
	    			 return row.distributorName;
	    		 }
	         }
	   },
        { "data": "distributorPhoneNo" },
        { "data": "distributorRebate" },
       /* { "data": "servantName" },
        { "data": "servantRebate" },*/
        { "data": "projectName" },
        { "data": "amount" },
        {
       	 render : function(data, type, row, meta) {
       		 if(row.isBalance == '0'){
       			 return '已结算';
       		 }else if(row.isBalance == '1'){
       			 return '未结算';
       		 }else {
       			 return '未知';
       		 }
            }
        }
    ],
    "drawCallback": function( settings ) {
     }
});

$('.integration-datatable').DataTable({
	 "ajax" : {
		"url" : contextpath + "/customer/ruleIntegrationDetail/" + $("#customerId").val(),
		"data" : function(d) {
         var query = $("#query").serializeObject();
         query["size"] = d.length;
         query["page"] = (d.start/d.length);
			return query;
		},
		"dataFilter": function(data){
         var json = jQuery.parseJSON( data );
         json.recordsTotal = json.totalElements;
         json.recordsFiltered = json.totalElements;
         json.data = json.content;

         return JSON.stringify( json );
     }
	 },
	 "columns": [
      { "data": "ruleName" },
      { "data": "integration" },
      { "data": "createTime" }
  ],
  "drawCallback": function( settings ) {
   }
});

$(function(){

	$('select').select2({
	    minimumResultsForSearch: Infinity
	});	
	
})
